//立即执行函数传入document简写成doc
; ((doc, storage,location) => {
    const oUsername = doc.querySelector('#username');
    const oEnterBtn = doc.querySelector('#enter');

    //初始化
    const init = () => {
        bindEvent();
    }

    //绑定事件
    function bindEvent() {
        oEnterBtn.addEventListener('click', handleEnterBtn, false);

    }

    function handleEnterBtn() {
        //trim()表示去掉空格     
        const username = oUsername.value.trim();

        if (username.length < 6) {
            alert('用户名不小于6位');
            return;
        }

        //将用户名保存在本地中
        storage.setItem('username',username);
        //跳转页面
        location.href='index.html';
    }

    init();

})(document, localStorage,location);